package com.clw.weblogin.service.impl;

import com.clw.weblogin.dao.DepartmentMapper;
import com.clw.weblogin.entity.Department;
import com.clw.weblogin.entity.DepartmentExample;
import com.clw.weblogin.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DepartmentServiceImpl implements DepartmentService {
    @Autowired
    DepartmentMapper mapper;

    public List<Department> selectdepart() {
        return mapper.selectByExample(null);
    }

    public String selectnameByid(Department department) {
        DepartmentExample example=new DepartmentExample();
        DepartmentExample.Criteria criteria=example.createCriteria();
        criteria.andDepartmentidEqualTo(department.getDepartmentid());
        List<Department> list=mapper.selectByExample(example);
        if(list.size()>0){
           return list.get(0).getDepartmentname();
        }
        return null;
    }
}
